//
//  THUserInfoModel.m
//  PublicProject
//
//  Created by TianHe_Wsk on 15/11/3.
//  Copyright © 2015年 H.D.X. All rights reserved.
//

#import "THUserInfoModel.h"


@implementation THUserInfoModel


-(void)encodeWithCoder:(NSCoder *)aCoder{
    
    NSArray *names = [NSArray gethdxProperties:[self class]];
    for (NSString *name in names) {
        id value = [self valueForKey:name];
        
        [aCoder encodeObject:value  forKey:name];
    }
    
}

-(id)initWithCoder:(NSCoder *)aDecoder{
    self = [super init];
    if (self) {
        //        self.userID =  [aDecoder decodeObjectForKey:@"userID"];
        //获取所有属性 ，遍历 给属性赋值
        NSArray *names = [NSArray gethdxProperties:[self class]];
        for (NSString *name in names) {
            [self  setValue:[aDecoder decodeObjectForKey:name] forKey:name];
            
        }
        
    }
    return self;
}

-(void)setAttributes:(NSDictionary *)userInfo{
    
    [super setAttributes:userInfo];
    
    //获取所有属性 ，遍历 给属性赋值
    NSArray *names = [NSArray gethdxProperties:[self class]];
    for (NSString *name in names) {
        if([[userInfo allKeys] containsObject:name]){
            [self  setValue:[userInfo objectForKey:name] forKey:name];
        }
        else{
            [self  setValue:@""  forKey:name];
        }
    }

    
}
@end
